import { Application } from '@sunmao-ui/core';

export const selection: Application = {
  kind: 'Application',
  version: 'example/v1',
  metadata: {
    name: 'selectionUsage',
    description: 'selectionUsage',
  },
  spec: {
    components: [
      {
        id: 'space1',
        type: 'arco/v1/space',
        properties: {
          align: 'center',
          direction: 'vertical',
          wrap: false,
          size: 'mini',
        },
        traits: [],
      },
      {
        id: 'radio3',
        type: 'arco/v1/radio',
        properties: {
          options: [
            {
              label: 'multiple',
              value: 'multiple',
              disabled: false,
            },
            {
              label: 'single',
              value: 'single',
              disabled: false,
            },
            {
              label: 'disable',
              value: 'disable',
              disabled: false,
            },
          ],
          type: 'button',
          defaultCheckedValue: 'single',
          direction: 'horizontal',
          size: 'default',
        },
        traits: [
          {
            type: 'core/v1/slot',
            properties: {
              container: {
                id: 'space1',
                slot: 'content',
              },
            },
          },
        ],
      },
      {
        id: 'table2',
        type: 'arco/v1/table',
        properties: {
          columns: [
            {
              title: 'Name',
              dataIndex: 'name',
              sorter: false,
              sortDirections: ['ascend', 'descend'],
              defaultSortOrder: 'ascend',
              type: 'text',
              filter: false,
            },
            {
              title: 'Salary',
              dataIndex: 'salary',
              sorter: false,
              filter: false,
              type: 'text',
            },
            {
              title: 'Time',
              dataIndex: 'time',
              sorter: false,
              filter: false,
              type: 'text',
            },
            {
              title: 'Link',
              dataIndex: 'link',
              type: 'link',
              filter: false,
              sorter: false,
            },
          ],
          data: [
            {
              key: 'key 0',
              name: 'Peter0',
              link: 'link-B',
              salary: 59,
              time: '2021-7-11T1:10:45.437Z',
            },
            {
              key: 'key 1',
              name: 'Peter1',
              link: 'link-A',
              salary: 371,
              time: '2021-1-11T11:10:45.437Z',
            },
            {
              key: 'key 2',
              name: 'Kevin Sandra2',
              link: 'link-A',
              salary: 779,
              time: '2021-10-11T4:10:45.437Z',
            },
            {
              key: 'key 3',
              name: 'Kevin Sandra3',
              link: 'link-A',
              salary: 107,
              time: '2021-7-11T4:10:45.437Z',
            },
            {
              key: 'key 4',
              name: 'Kevin Sandra4',
              link: 'link-A',
              salary: 610,
              time: '2021-7-11T11:10:45.437Z',
            },
            {
              key: 'key 5',
              name: 'Peter5',
              link: 'link-A',
              salary: 297,
              time: '2021-6-11T8:10:45.437Z',
            },
            {
              key: 'key 6',
              name: 'Peter6',
              link: 'link-A',
              salary: 799,
              time: '2021-0-11T9:10:45.437Z',
            },
            {
              key: 'key 7',
              name: 'Peter7',
              link: 'link-B',
              salary: 242,
              time: '2021-10-11T0:10:45.437Z',
            },
            {
              key: 'key 8',
              name: 'Peter8',
              link: 'link-B',
              salary: 798,
              time: '2021-2-11T2:10:45.437Z',
            },
            {
              key: 'key 9',
              name: 'Peter9',
              link: 'link-B',
              salary: 947,
              time: '2021-1-11T9:10:45.437Z',
            },
            {
              key: 'key 10',
              name: 'Kevin Sandra10',
              link: 'link-B',
              salary: 927,
              time: '2021-4-11T0:10:45.437Z',
            },
            {
              key: 'key 11',
              name: 'Kevin Sandra11',
              link: 'link-A',
              salary: 463,
              time: '2021-10-11T5:10:45.437Z',
            },
            {
              key: 'key 12',
              name: 'Kevin Sandra12',
              link: 'link-B',
              salary: 396,
              time: '2021-9-11T3:10:45.437Z',
            },
          ],
          pagination: {
            pageSize: 6,
          },
          tableLayoutFixed: false,
          borderCell: false,
          stripe: false,
          size: 'default',
          pagePosition: 'bottomCenter',
          rowSelectionType: '{{radio3.checkedValue}}',
        },
        traits: [
          {
            type: 'core/v1/slot',
            properties: {
              container: {
                id: 'space1',
                slot: 'content',
              },
            },
          },
        ],
      },
      {
        id: 'text2',
        type: 'core/v1/text',
        properties: {
          value: {
            raw: "Current Selected Person: {{table2.selectedRows.map(r => r.name).join(', ')}}",
            format: 'plain',
          },
        },
        traits: [
          {
            type: 'core/v1/slot',
            properties: {
              container: {
                id: 'space1',
                slot: 'content',
              },
            },
          },
        ],
      },
    ],
  },
};
